﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_zzjg_DeleteZzjg]
	(
	@id int	
	)
AS
BEGIN	
    
    DECLARE @xs INT
    SET @xs=ISNULL((SELECT COUNT(1) FROM zzjg z WHERE z.pid=@id),0) --查询有多少下级结点
    IF @xs>0
    BEGIN
    	RETURN
    END                                                                            
    
    DELETE FROM ManagementArea WHERE zid=(select bh from zzjg where id=@id)
	DELETE FROM zzjg WHERE id=@id
	
END
